-- Channel Mod
-- CLIENTSIDE

local function Override_Paint( element )
	element.Paint = function() end
end

local function Separator(a, b)
	local v = vgui.Create( "DPanel", a )
	v:SetSize( 1, b or 20 )
	Override_Paint( v )
	return v
end

surface.CreateFont( "Lucida Console", 35, 400, true, false, "ChanCreHeader")

timer.Simple( 0, function()


-- Frame
local Frame = vgui.Create( "DFrame" )
Frame:SetSize( 500, ScrH() * 0.7 )
Frame:Center()
Frame:SetTitle( "Channels" )
Frame:SetDeleteOnClose( false )
Frame:MakePopup()
Frame:SetVisible( false )

Channels.Window = Frame

concommand.Add( "chan_show", function()
	Channels.Window:SetVisible( true )
end )

-- Column Sheet
local Sheet = vgui.Create( "DColumnSheet", Frame )
Sheet:UseButtonOnlyStyle()
	Sheet.Navigation:Dock( RIGHT )
	Sheet.Navigation:SetWidth( 16 )
	Sheet.Navigation:DockMargin( 3, 0, 0, 0 )

Sheet:SetSize( 500 - 10, Frame:GetTall() - 30 )
Sheet:SetPos( 5, 25 )

	-- Channel Listing
	local CList = vgui.Create( "ChannelList", Sheet )
	CList:Dock( FILL )
	CList:SetMultiple( false )

	CList:AddItem( "Choose a channel, or use the buttons on the side to create one!" ).SetSelected = function() end 
	
	Channels.List = CList

------
Sheet:AddSheet( "Channel List", CList, "gui/silkicons/application_view_detail" )

	local Form = vgui.Create( "DPanelList", Sheet )
	Form:Dock( FILL )
	Form:SetPadding( 10 )
	Form:SetName( "Channel Creation" )

	local Header = vgui.Create( "DLabel", Form )
	Header:SetText( "Channel Creation" )
	Header:SetFont( "ChanCreHeader" )
	Header:SizeToContents()
		Form:AddItem( Header )

	local ChanLabel = vgui.Create( "DLabel", Form )
	ChanLabel:SetText( "Please enter the name of your channel here. This can't contain any spaces. E.g.: TeamOne, wepwn, snipozos." )
	ChanLabel:SetWrap( true )
	ChanLabel:SetTall( 30 )
		Form:AddItem( ChanLabel )

	Form:AddItem( Separator( Form, 5 ) )

	local ChanName = vgui.Create( "ChannelEntry", Form )
	ChanName:SetWide( 300 )
		Form:AddItem( ChanName )
		
	Form:AddItem( Separator( Form, 15 ) )

	local ChanIDLabel = vgui.Create( "DLabel", Form )
	ChanIDLabel:SetText( "Enter the ID for your channel. No spaces, will automatically be lowercased. This is what will be shown when you chat in the channel, e.g. Bob [my-channel]: Hello" )
	ChanIDLabel:SetWrap( true )
	ChanIDLabel:SetTall( 30 )
		Form:AddItem( ChanIDLabel )

	Form:AddItem( Separator( Form, 5 ) )
	
	local ChanID = vgui.Create( "ChannelEntry", Form )
	ChanID:SetWide( 300 )
		Form:AddItem( ChanID )
		
	Form:AddItem( Separator( Form, 15 ) )
	
	local ChanPLabel = vgui.Create( "DLabel", Form )
	ChanPLabel:SetText( "If you'd like to protect your channel with a password, type it below. Again, no spaces, and it can't be changed later." )
	ChanPLabel:SetWrap( true )
	ChanPLabel:SetTall( 30 )
		Form:AddItem( ChanPLabel )
		
	Form:AddItem( Separator( Form, 5 ) )

	local ChanPass = vgui.Create( "ChannelEntry", Form )
		Form:AddItem( ChanPass )
		
	Form:AddItem( Separator( Form, 5 ) )
		
	local ChanOKPan = vgui.Create( "DPanel", Form )
	Override_Paint( ChanOKPan )

	local ChanOK = vgui.Create( "DButton", ChanOKPan )
	ChanOK:SetWide( 100 )
	ChanOK:SetText( "Create Channel" )
	function ChanOK:DoClick()
		RunConsoleCommand( "chan_create", ChanName:GetValue(), ChanID:GetValue(), ChanPass:GetValue() )
	end

	ChanOKPan:SizeToContents()
		Form:AddItem( ChanOKPan )

	ChanOK:Dock( TOP )
	ChanOK:DockMargin( 150, 0, 150, 5 )

------
Sheet:AddSheet( "Channel Creation", Form, "gui/silkicons/wrench" )


end )